package com.ruoyi.customer.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.customer.domain.Dragging;
import com.ruoyi.customer.service.DraggingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 拖柜
 *
 * @Author:zzm
 * @Date: 2024/8/29 15:26
 */
@RestController
@RequestMapping("/amac/dragging")
public class DraggingController extends BaseController {

    @Autowired
    private DraggingService draggingService;

    /**
     * 设置请求分页数据
     */
    protected void startPage() {
        PageUtils.startPage();
    }

    /**
     * 查询列表
     *
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list() {
        startPage();
        List<Dragging> list = draggingService.getList();
        return getDataTable(list);
    }

    /**
     * 新增/修改
     */
    @PutMapping("/addOrUpdate")
    public AjaxResult addOrUpdate(@RequestBody Dragging ro) {
        return toAjax(draggingService.addOrUpdate(ro));
    }

    /**
     * 删除
     *
     * @param ids
     * @return
     */
    @DeleteMapping("/{ids}")
    public AjaxResult deleteByIds(@PathVariable Long[] ids) {
        draggingService.delete(ids);
        return AjaxResult.success(true);
    }
}
